﻿using System;
using com.diagnosis.tool.xml;

namespace DiagnosisToolBL
{
    public class ExtendedDiseaseForDisplay : IComparable 
    {
        private readonly String     mDiseaseName;
        private readonly int        mHitNumber;
        private readonly int        mMissNumber;
        private readonly int        mTotalSymptoms;

        public ExtendedDiseaseForDisplay(
            Disease pDisease,
            int     pHitNumber,
            int     pMissNumber,
            int     pTotalSymptoms)
        {
            mDiseaseName    = pDisease.DiseaseName;
            mHitNumber      = pHitNumber;
            mMissNumber     = pMissNumber;
            mTotalSymptoms  = pTotalSymptoms;
        }

        public String DiseaseName
        {
            get { return mDiseaseName; }
        }

        public int HitNumber
        {
            get { return mHitNumber; }
        }

        public int MissNumber
        {
            get { return mMissNumber; }
        }

        public override string ToString()
        {
            return mDiseaseName + " (" + mHitNumber +
                   " of " + mTotalSymptoms + ")";
        }

        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return -1;
            }
            var other = (ExtendedDiseaseForDisplay) obj;

            return other.GetRatio().CompareTo(GetRatio());
        }

        private Double GetRatio()
        {
            return ( 
                 (double) mHitNumber/ 
                 (double) mTotalSymptoms);
        }

    }
}
